<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        class Person{
            constructor(){
                // this.name = "张三";
            }
            get name(){
                console.log("在获取name属性的时候触发get函数")
                return "张三"; 
            }
            set name(newvalue){
                console.log("设置name值的时候触发set函数",newvalue);
            }
        }

        let zhangsan = new Person();
        // console.log(zhangsan);
        setTimeout(()=>{
            zhangsan.name = "1111";

        },2000)



    </script>
</body>
</html>